import { addCustomBlocks } from "../blocks/homePage/addCustomBlocks";
import { addCaseCard } from "../blocks/homePage/addCaseCard";
import { addNavBar } from "../blocks/homePage/addNavBar";
import { addColumn } from "../blocks/homePage/addColumn";
import { addLastIntroduce } from '../blocks/homePage/addLastIntroduce';
export const HomePageBlockManager = (editor) => {
  // ------------------------------------------------------------------------------------------------------------
  /*
    添加自定义块CustomBlocks组件
  */
  addCustomBlocks(editor);

  // ------------------------------------------------------------------------------------------------------------
  /*
    添加案例卡片组件
  */
  addCaseCard(editor);
  editor.BlockManager.add("CaseCard", {
    label: "案例卡片",
    category: "首页组件",
    select: true,
    media:`<svg t="1720768327577" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="15366" width="30" height="30"><path d="M860.2 159.3H729.7c-19.8-94.7-121.3-95-204.8-95s-185.1 0.3-204.8 95h-154c-28.9 0-52.4 23.5-52.4 52.4v695.5c0 28.9 23.5 52.4 52.4 52.4h694.1c28.9 0 52.4-23.5 52.4-52.4V211.7c-0.1-28.9-23.5-52.4-52.4-52.4z m-481 35.5c0-59.2 31-67.6 145.7-67.6s145.7 8.4 145.7 67.6v31.4H379.2v-31.4z m470.5 701.9H176.6V222.2h139.8V289h417.1v-66.9h116.2v674.6z" p-id="15367"></path><path d="M289.7 402.7c-17.4 0-31.4 14.1-31.4 31.4s14.1 31.4 31.4 31.4h471.5c17.4 0 31.4-14.1 31.4-31.4s-14.1-31.4-31.4-31.4H289.7zM642.9 556.3H289.7c-17.4 0-31.4 14.1-31.4 31.4s14.1 31.4 31.4 31.4h353.2c17.4 0 31.4-14.1 31.4-31.4s-14.1-31.4-31.4-31.4zM524.9 724H289.7c-17.4 0-31.4 14.1-31.4 31.4s14.1 31.4 31.4 31.4h235.2c17.4 0 31.4-14.1 31.4-31.4s-14-31.4-31.4-31.4z" p-id="15368"></path></svg>`,
    content: { type: "CaseCard" },
  });

  // ------------------------------------------------------------------------------------------------------------
  /*
    注册顶部导航栏组件
  */
  const opts = {
    id: "navbar",
    label: "Navbar",
    classPrefix: "navbar",
    style: "",
    styleAdditional: "",
  };
  addNavBar(editor, opts);
  editor.BlockManager.add("navbar", {
    // 分类的展示图标
    media: `<svg viewBox="0 0 24 24" style="width:30px; height:30px">
            <path d="M22 9c0-.6-.5-1-1.25-1H3.25C2.5 8 2 8.4 2 9v6c0 .6.5 1 1.25 1h17.5c.75 0 1.25-.4 1.25-1V9Zm-1 6H3V9h18v6Z"/><path d="M15 10h5v1h-5zM15 13h5v1h-5zM15 11.5h5v1h-5z"/>
        </svg>`,
    label: "顶部导航",
    category: "首页组件",
    select: true,
    content: { type: "navbar" },
  });

  // ------------------------------------------------------------------------------------------------------------
  /*
    栏目组件
  */
  const opt = {
    ColumnBlock: { category: "首页组件", label: "栏目组件" }, // 用来扩展默认的flexbox块
    stylePrefix: "gjs-", // Class类的前缀
    labelRow: "Row", // 行标签
    labelColumn: "Column", // 列标签
  };
  addColumn(editor, opt);

  // -------------------------------------------------------------------------------------------------------------
  /*
    官网页尾介绍组件
  */
  addLastIntroduce(editor);
};
